clc
clear


t = 0:0.01:2*pi;
y = sawtooth(t, 0.5);
k = 1:2:41;
fourier_y = 0;

for i = 1:1:20
    fourier_y = fourier_y + 8/(k(i)^2 * pi^2) * sin(k(i) * t);
end

plot(t,fourier_y,'b')

R=1;
C=1;
w_0=1/(R*C);
H_1p_p = 1i*k*R*C./(1+1i*k*R*C);
r_p = abs(H_1p_p);
theta_p = angle(H_1p_p);

fourier_y_lp=0;

for i =1:1:20
    fourier_y_lp = fourier_y_lp+2*r_p(i)/(k(i)*pi)*sin(2*pi*k(i)*t+theta_p(i));
end

figure(2);
plot(t,y,'r');grid on;hold on;
plot(t,fourier_y_lp,'b')
